13.5 Starters
1 | Starters are a set of convenient dependency descriptors that |
“Starters”是一组可以导入到您的应用中的方便可用的依赖描述符。您将可以在不需要通过示例代码搜索拷贝-粘贴的情况下一站式获得所有关于Spring相关联的技术依赖。举个例子,如果您选择使用Spring和JPA作为数据库接入组件,导入spring-boot-starter-data-jpa依赖进您的工程即可。
1 | The starters contain a lot of the dependencies that you need |
这些“Starters”包含很多您需要的让项目快速启动的依赖,并保持一致,支持一组受管控的传递依赖。
1 | What’s in a name |
名字中包含了什么?
所有的官方“starters”遵循一个相同的命名规范;spring-boot-starter-,
““是代表特定类型的应用。这种命名结构能够在您需要寻找一个“starter”的时候提供有利的帮助。
在许多集成了Maven的IDE中,您都可以按名称搜索依赖项。比如,通过安装适当的Eclipse或STS插件,
你可以在POM编辑器中按ctrl-space并键入“spring-boot-starter”获取完整列表。
如上所述,“创建您自己的Starter”,第三方“starters”不应该使用spring-boot作为开头,因为他是为官方Spring Boot保留的。然而,一个第三方的starter一般以工程名开始。举个例子,一个第三方的starter工程名为“thirdpartyproject”,可以以“thirdpartyproject-spring-boot-starter”来命名。1
2The following application starters are provided by Spring Boot
under the org.springframework.boot group:
如下应用的starters被Spring Boot提供,在 org.springframework.boot group下
| 名字 | 描述 |
|---|---|
| spring-boot-starter | 核心starter, 包括自动配置支持, 日志和YMAL支持。 |
| spring-boot-starter-activemq | Starter用于JMS消息,使用Apache的ActiveMQ |
| spring-boot-starter-amqp | Starter用于使用Spring AMQP 和Rabbit MQ |
| spring-boot-starter-aop | Starter用于在Spring AOP 和 AspectJ下的面相切面编程 |
| spring-boot-starter-artemis | Starter用于JMS消息 ,应用于 Apache Artemis |
| spring-boot-starter-batch | Starter 用于使用Spring Batch |
| spring-boot-starter-cache | Starter用于使用Spring Framework下的缓存支持 |
| spring-boot-starter-cloud-connectors | Starter用于Spring Cloud连接,它简化了连接到Cloud Foundry和Heroku等云平台的服务 |
| spring-boot-starter-data-cassandra | Starter用于使用Cassandra分布式数据库和Spring Data Cassandra |
| spring-boot-starter-data-cassandra-reactive | Starter用于使用Cassandra分布式数据库和Spring Data Cassandra Reactive |
| spring-boot-starter-data-couchbase | Starter用于Couchbase面向文档的数据库和Spring Data Couchbase |
| spring-boot-starter-data-couchbase-reactive | Starter用于使用Couchbase面向文档的数据库和Spring Data Couchbase Reactive |
| spring-boot-starter-data-elasticsearch | Starter用于使用Elasticsearch 查找分析引擎 和 Spring Data Elasticsearch |
| spring-boot-starter-data-jpa | Starter用于Spring Data JPA和Hibernate |
| spring-boot-starter-data-ldap | Starter用于Spring Data LDAP |
| spring-boot-starter-data-mongodb | Starter用于MongoDB 基于文档的数据库和Spring Data MongoDB |
| spring-boot-starter-data-mongodb-reactive | Starter用于使用MongoDB面向文档的数据库和Spring Data MongoDB Reactive |
| spring-boot-starter-data-neo4j | Starter用于使用Neo4j图形数据库和Spring Data Neo4jPom |
| spring-boot-starter-data-redis | Starter用于在Spring Data Redis和Lettuce客户端中使用Redis键值数据存储 |
| spring-boot-starter-data-redis-reactive | Starter用于使用Redis键值数据存储以及Spring Data Redis反应器和Lettuce客户端 |
| spring-boot-starter-data-rest | Starter用于使用Spring Data REST将Spring Data存储库暴露于REST |
| spring-boot-starter-data-solr | Starter用于在Spring Data Solr中使用Apache Solr搜索平台 |
| spring-boot-starter-freemarker | Starter用于基于FreeMarker View的MVC web应用 |
| spring-boot-starter-groovy-templates | Starter用于建设基于Groovy模板的MVC web应用 |
| spring-boot-starter-hateoas | Starter用于使用Spring MVC和Spring HATEOAS构建基于超媒体的RESTful Web应用程序 |
| spring-boot-starter-integration | Starter用于使用Spring Integration |
| spring-boot-starter-jdbc | Starter用于使用JDBC和HikariCP连接池的入门者 |
| spring-boot-starter-jersey | Starter用于建设基于JAX-RS and Jersey的RESTful web应用Spring-Boot-Starter-Web的另一种选择 |
| spring-boot-starter-jooq | Starter用于JPPQ数据连接框架.spring-boot-starter-data-jpa 和 spring-boot-starter-jdbc的替代者 |
| spring-boot-starter-json | Starter用于读写json |
| spring-boot-starter-jta-atomikos | Starter用于使用Atomikos的JTA事务 |
| spring-boot-starter-jta-bitronix | Starter用于使用Bitronix的JTA事务 |
| spring-boot-starter-jta-narayana | Starter用于使用Narayana的JTA事务 |
| spring-boot-starter-mail | Starter用于使用Java Mail 和 Spring Framework的email发送支持 |
| spring-boot-starter-mustache | Starter用于建设基于Mustache views的web应用 |
| spring-boot-starter-quartz | Starter用于Quartz scheduler定时器任务 |
| spring-boot-starter-security | Starter用于使用Spring Security |
| spring-boot-starter-test | Starter用于测试Spring Boot应用包含JUnit, Hamcrest 和 Mockito |
| spring-boot-starter-thymeleaf | Starter用于基于thymeleaf视图的的MVC应用建设 |
| spring-boot-starter-validation | Starter用于使用Java Bean的检验框架,基于hibernate的校验器 |
| spring-boot-starter-web | Starter用于构建web应用, 包含RESTful, 应用基于使用 Spring MVC. 使用Tomcat作为默认的容器 |
| spring-boot-starter-web-services | Starter用于使用Spring Web Services |
| spring-boot-starter-webflux | Starter用于使用WebFlux Spring Framework’s Reactive Web 支持 |
| spring-boot-starter-websocket | Starter用于构建基于Spring Framwork的websocket支持 |
1 | In addition to the application starters, the following |
除了应用级别的starters以外,下面的这个starter具备产品级功能应用。1
Table 13.2. Spring Boot production starters
Spring Boot的产品级starters
名字 | 描述
——— | ————-
spring-boot-starter-actuator|Starter用于Spring Boot 的 Actuator,它是用于提供产品级别的应用管理和监控功能
1 | Finally, Spring Boot also includes the following starters that can be used if you want to exclude or swap specific technical facets: |
最后,Spring Boot还提供了如下的starters用于帮助您排除或者替代的starters
1 | Table 13.3. Spring Boot technical starters |
Spring Boot技术starters
名字 | 描述
——— | ————-
spring-boot-starter-jetty|Starter用于使用基于servlet技术的内置jetty容器。 可以用于替代spring-boot-starter-tomcat
spring-boot-starter-log4j2|Starter用于基于log4j2的日志处理。可以替代现有的spring-boot-starter-logging
spring-boot-starter-logging|Starter用于基于Logback的日志处理. 也是默认的日志处理器。
spring-boot-starter-reactor-netty|Starter用于Reactor Netty作为内置容器的响应式HTTP 服务器.
spring-boot-starter-tomcat|Starter用于内置的Tomcat容器,如果使用spring-boot-starter-web依赖的话,会将此作为默认以来
spring-boot-starter-undertow|Starter用于基于undertow的内置容器,spring-boot-starter-tomcat的替代者。
1 | For a list of additional community contributed starters, see the |
如果想要获得社区贡献的更多的starters,请阅读GitHub上spring-boot-starters模块的README文件。